<template>
  <div class="myhome">
    <header>
      <div class="search">
        <div class="log">
          <img src="../../public/images/img/arrow_left.png" alt="" />
        </div>
        <div class="sear">我的书城</div>
        <div class="cai">
          <img src="../../public/images/img/menu.png" alt="" />
        </div>
      </div>
    </header>
    <main>
      <div class="login">
        <router-link to="/loginUser" v-if="!username">登录/注册</router-link>

        <div class="wrap" v-if="username">
          <div class="user_img">
            <img src="../../public/images/img/header_o.png" alt="" />
          </div>
          <div class="user_detail">
            <div class="user_name">
              <span>{{username}}</span>
              <img src="../../public/images/img/v0.png" alt="" />
            </div>
            <div class="remaining">
              <span>余额 0.00</span>
              <span>礼品卡 0.00</span>
              <span class="ji_fen">积分 0.00</span>
            </div>
          </div>

          <!--  -->
          <!-- <div class="user_main">
            <img src="../../public/images/img/personal.png" alt="">
          </div> -->
        </div>
      </div>

      <div class="my">
        <div class="li">
          <i>0</i>
          <span>收藏的商品</span>
        </div>
        <div class="li">
          <i>0</i>
          <span>关注的店铺</span>
        </div>
        <div class="li">
          <i>0</i>
          <span>我的足迹</span>
        </div>
      </div>

      <router-link to="/orders?id=0" tag="div" class="dingdan">
        <div class="left">
          <img src="../../public/images/img/wd-012-1.png" alt="" />
          我的订单
        </div>
        <div class="right">
          查看全部购买商品
          <img src="../../public/images/img/ddcategory_more_icon.png" alt="" />
        </div>
      </router-link>

      <div class="order-nav">
        <ul>
          <li>
            <router-link to="/orders?id=1"
              ><img src="../../public/images/img/fukuan-07.png" alt="" /><span
                >待付款</span
              >
            </router-link>
          </li>
          <li>
            <router-link to="/orders?id=2"
              ><img src="../../public/images/img/shouhuo-07.png" alt="" /><span
                >待收货</span
              >
            </router-link>
          </li>
          <li>
            <router-link to="/orders?id=3"
              ><img src="../../public/images/img/pd-return.png" alt="" /><span
                >退还货</span
              >
            </router-link>
          </li>
        </ul>
      </div>

      <div class="hr"></div>

      <div class="dingdan">
        <div class="left">
          <img src="../../public/images/img/vip-1521514865.png" alt="" />
          会员中心
        </div>
        <div class="right">
          <img src="../../public/images/img/ddcategory_more_icon.png" alt="" />
        </div>
      </div>

      <div class="hr"></div>

      <div class="dingdan">
        <div class="left">
          <img src="../../public/images/img/wd-012-02.png" alt="" />
          我的礼券
        </div>
        <div class="right">
          <img src="../../public/images/img/ddcategory_more_icon.png" alt="" />
        </div>
      </div>

      <div class="dingdan">
        <div class="left">
          <img src="../../public/images/img/wd-012-03.png" alt="" />
          积分抵现
        </div>
        <div class="right">
          <img src="../../public/images/img/ddcategory_more_icon.png" alt="" />
        </div>
      </div>

      <div class="dingdan">
        <div class="left">
          <img src="../../public/images/img/111.png" alt="" />
          我的电子书
        </div>
        <div class="right">
          <img src="../../public/images/img/ddcategory_more_icon.png" alt="" />
        </div>
      </div>

      <div class="dingdan">
        <div class="left">
          <img src="../../public/images/img/wd-012-04.png" alt="" />
          我的礼品卡
        </div>
        <div class="right">
          <img src="../../public/images/img/ddcategory_more_icon.png" alt="" />
        </div>
      </div>

      <router-link to="/addressbook" tag="div" class="dingdan">
        <div class="left">
          <img src="../../public/images/img/wd-012-05.png" alt="" />
          收货地址
        </div>

        <div class="right">
          <img src="../../public/images/img/ddcategory_more_icon.png" alt="" />
        </div>
      </router-link>

      <div class="hr"></div>
      <div class="dingdan">
        <div class="left">
          <img src="../../public/images/img/wd-012-07.png" alt="" />
          客服反馈
        </div>

        <div class="right">
          <img src="../../public/images/img/ddcategory_more_icon.png" alt="" />
        </div>
      </div>

      <!-- <div class="hr"></div> -->

      <!-- <div class="like-list">
        <div class="head">
          <div><i></i> <b>根据您的偏好猜您可能喜欢</b></div>
        </div>
      </div>
      <div class="likes">
        <ul>
          <router-link :to="{name:'detail',query:{data:1,id:item.id} }" tag="li" v-for="(item) in booksData" :key="item.id">
            <img :src="item.img[0]" alt="" />
            <p>{{item.name}}</p>
            <div class="xin">
              <span :class="value.label1?'con':''" v-for="(value,index) in item.labels" :key="index">{{value.label_common}}</span>
            
            </div>
            <div class="prec"><i>￥</i><span>{{(item.money).toFixed(2)}}</span></div>
            <div class="pinjia">{{item.pNum}}人评价</div>
          </router-link>
          
        </ul>
      </div> -->
      <enjoy-list></enjoy-list>
    </main>

    <footer-nav></footer-nav>
  </div>
</template>

<script>
import FooterNav from "../components/FooterNav.vue";
import { getHomepageBall } from "../api/home";
import EnjoyList from "../components/EnjoyList.vue";

export default {
  components: { FooterNav, EnjoyList },
  data() {
    return {
      booksData: [],
      userLogin: false,
      username: null,
    };
  },
  methods: {
    getHomepageBallFun() {
      getHomepageBall().then((data) => {
        this.booksData = data.booksData;
        // console.log(this.booksData);
      });
    },

    getUser() {
      if (window.localStorage.getItem("token")) {
        let { name } = JSON.parse(window.localStorage.getItem("token"));
        this.username = name;
      }
    },
  },
  created() {
    this.getHomepageBallFun();
    this.getUser();
  },
};
</script>

<style lang="scss" scoped>
.myhome {
  padding-bottom: 40px;
  .search {
    height: 44px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #d8d8d8;
    box-sizing: border-box;
    .log {
      width: 40px;
      height: 39.5px;
      display: flex;
      justify-content: center;
      align-items: center;
      img {
        width: 10px;
        height: 17px;
      }
    }
    .cai {
      width: 40px;
      height: 39.5px;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-left: 8px;
      img {
        width: 21px;
        height: 7px;
      }
    }
    .sear {
      height: 100%;
      flex: 1;
      display: flex;
      align-items: center;
      font-size: 17px;
      justify-content: center;
      color: #333;
      i {
        width: 14px;
        height: 14px;
        display: block;
        margin: 0 9px;
        font-weight: bold;
        color: #767b83;
      }
      span {
        color: #999999;
        font-size: 14px;
      }
    }
  }
  .login {
    width: 100%;
    height: 116px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: url("../../public/images/img/user-bg.jpg") center no-repeat;
    background-size: cover;
    // padding: 13.5px;
    .wrap {
      width: 100%;
      padding: 20.5px 13.5px;
      display: flex;
      position: relative;
      .user_main {
        position: absolute;
        width: 90px;
        height: 30px;
        right: 0;
        bottom: 10px;
        img {
          width: 100%;
          display: block;
        }
      }
      .user_detail {
        color: #fff;
        margin-left: 15px;
        flex: 1;
        .remaining {
          margin-top: 8px;
          font-size: 12px;
          span {
            margin-right: 5px;
          }
          .ji_fen {
            position: relative;
          }
          .ji_fen::before {
            content: "";
            display: block;
            width: 44px;
            height: 13px;
            position: absolute;
            top: -13px;
            right: 0;
            background-image: url("../../public/images/img/sign_tag.gif");
            background-repeat: no-repeat;
            background-position: center;
            background-size: cover;
          }
        }
        .user_name {
          display: flex;
          font-size: 18px;
          img {
            width: 20px;
            margin-left: 4px;
          }
        }
      }
      .user_img {
        width: 74px;
        height: 74px;
        img {
          display: block;
          width: 100%;
          height: auto;
          border-radius: 8px;
        }
      }
    }
    a {
      color: #fff;
      font-size: 16px;
      border: 1px solid #fff;
      height: 36px;
      width: 116px;
      border-radius: 19px;
      text-align: center;
      line-height: 36px;
    }
  }
  .my {
    width: 100%;
    padding: 9px 0;
    display: flex;
    border-bottom: 2px solid #fafafa;
    .li {
      width: 33%;
      height: 35px;
      border-right: 2px solid #fafafa;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      i {
        font-size: 13px;
      }
      span {
        font-size: 13px;
      }
      &:last-child {
        border: none;
      }
    }
  }
  .dingdan {
    height: 44px;
    display: flex;
    justify-content: space-between;
    padding-left: 9px;
    padding-right: 14px;
    align-items: center;
    border-bottom: 2px solid #fafafa;
    .left {
      font-size: 14px;
      color: #4d525d;
      display: flex;
      img {
        width: 23px;
        height: 22px;
        display: block;
        margin-right: 4px;
      }
    }
    .right {
      font-size: 12px;
      color: #aea6ae;
      display: flex;
      img {
        width: 6px;
        height: 12px;
        display: block;
        margin-left: 6px;
        margin-top: 2px;
      }
    }
  }
  .order-nav {
    height: 52px;
    border-bottom: 1px solid #fafafa;
    ul {
      display: flex;
      li {
        width: 33.3333%;
        a {
          display: block;
          width: 100%;
          padding-top: 10px;
          padding-bottom: 4px;
          display: flex;
          flex-direction: column;
          align-items: center;
          img {
            width: 23px;
            height: 23px;
            display: block;
            margin-bottom: 3px;
          }
          span {
            font-size: 12px;
          }
        }
      }
    }
  }
  .hr {
    height: 10px;
    background-color: #eeeeee;
    border-top: 1px solid #f6f6f6;
    border-bottom: 1px solid #f6f6f6;
  }
  // .like-list {
  //   width: 100%;
  //   border-top: 2px solid #eee;
  //   .head {
  //     height: 51px;
  //     font-size: 15px;
  //     display: flex;
  //     align-items: center;
  //     justify-content: center;
  //     background-color: #f2f2f2;
  //     position: relative;
  //     div {
  //       background-color: #f2f2f2;
  //       display: flex;
  //       justify-content: center;
  //       align-items: center;
  //       z-index: 1;
  //       padding: 0 12px;
  //     }
  //     &::after {
  //       content: "";
  //       position: absolute;
  //       left: 7%;
  //       font-size: 0;
  //       line-height: 0;
  //       background-color: #dadada;
  //       height: 1px;
  //       width: 85%;
  //     }
  //     i {
  //       z-index: 1;
  //       display: block;
  //       width: 18px;
  //       height: 18px;
  //       background: url("../../public/images/img/下载\ \(1\).png") center
  //         no-repeat;
  //       background-size: cover;
  //       margin-right: 5px;
  //     }
  //     b {
  //       font-weight: normal;
  //       z-index: 1;
  //       font-size: 13px;
  //       color: #323232;
  //     }
  //   }
  // }
  // .likes {
  //   width: 100%;
  //   background-color: #f2f2f2;
  //   ul {
  //     display: flex;
  //     flex-wrap: wrap;
  //     justify-content: space-between;
  //     li {
  //       width: 49.5%;
  //       background-color: #fff;
  //       padding-bottom: 8.7px;
  //       margin-bottom: 4px;
  //       img {
  //         width: 100%;
  //         display: block;
  //       }
  //       p {
  //         padding: 5px 5px 0;
  //         color: #232323;
  //         font-size: 14px;
  //         margin-bottom: 2px;
  //         text-overflow: ellipsis;
  //         overflow: hidden;
  //         display: -webkit-box;
  //         -webkit-box-orient: vertical;
  //         -webkit-line-clamp: 2;
  //       }
  //       .xin {
  //         color: #f2303c;
  //         font-size: 12px;
  //         padding-left: 5px;
  //         span {
  //           border: 1px solid #f2303c;
  //           border-radius: 2px;
  //           margin-right: 4px;

  //         }
  //         span.con{
  //             background-color: #f2303c;
  //             color: #fff;
  //         }
  //       }
  //       .prec {
  //         margin-top: 5px;
  //         padding-left: 5px;
  //         color: #e53e30;
  //         span {
  //           font-size: 16px;
  //         }
  //         em {
  //           font-size: 14px;
  //         }
  //       }
  //       .pinjia {
  //         margin-top: 5px;
  //         font-size: 12px;
  //         color: #b4b4b4;
  //         padding-left: 5px;
  //       }
  //     }
  //   }
  // }
}
</style>